import 'package:enterprise_v6_app/app/core/core.dart';

/// @description  自适应的圆线UI(时间轴)
/// @param showWidget 展示的组件
/// @param spaceWidth 空白宽度
/// @param reverse 自适应的圆线UI是否反方向
class CustomIntrinsicCircleLine extends StatelessWidget {
  const CustomIntrinsicCircleLine({
    required this.showWidget,
    super.key,
    this.spaceWidth,
    this.iconSpaceHeight,
    this.iconWidget,
    this.spaceMargin,
    this.reverse = false,
  });

  final Widget showWidget; // 展示的组件
  final double? iconSpaceHeight; //圆形距顶部的距离
  final Widget? iconWidget; // 左侧图标
  final double? spaceWidth; //左侧与右侧的间距
  final EdgeInsetsGeometry? spaceMargin; //整体外边距
  final bool reverse; //自适应的圆线UI是否反方向

  @override
  Widget build(BuildContext context) {
    return Container(
      margin: spaceMargin ?? EdgeInsets.zero,
      child: IntrinsicHeight(
        child: Row(
          crossAxisAlignment: CrossAxisAlignment.start,
          children: [
            Column(
              children: [
                SizedBox(
                  height: iconSpaceHeight ?? 6.w,
                ),
                iconWidget ??
                    Container(
                      width: 10.w,
                      height: 10.w,
                      decoration: BoxDecoration(
                        shape: BoxShape.circle,
                        border: Border.all(
                          color: const Color(0xff5C6DFF),
                          width: 2.w,
                        ),
                      ),
                    ),
                Expanded(
                    child: Container(
                  width: 1.w,
                  decoration: BoxDecoration(
                      borderRadius: BorderRadius.all(Radius.circular(2.w)),
                      gradient: reverse
                          ? const LinearGradient(
                              //渐变位置
                              begin: Alignment.topCenter,
                              end: Alignment.bottomCenter,
                              //渐变颜色[始点颜色, 结束颜色]
                              colors: [ Colors.white,Color(0xff557CFD)])
                          : const LinearGradient(
                              //渐变位置
                              begin: Alignment.topCenter,
                              end: Alignment.bottomCenter,
                              //渐变颜色[始点颜色, 结束颜色]
                              colors: [Color(0xff557CFD), Colors.white])),
                  // height: 10.w,
                ))
              ],
            ),
            SizedBox(
              width: spaceWidth ?? 6.w,
            ),
            Expanded(child: showWidget)
          ],
        ),
      ),
    );
  }
}
